using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace CMSApplication.Models.Mapping
{
    public class HtmlElementMap : EntityTypeConfiguration<HtmlElement>
    {
        public HtmlElementMap()
        {
            // Primary Key
            this.HasKey(t => t.ElementID);

            // Properties
            this.Property(t => t.ElementType)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ID)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Name)
                .HasMaxLength(50);

            this.Property(t => t.Style)
                .HasMaxLength(50);

            this.Property(t => t.InnerHtml)
                .IsRequired()
                .HasMaxLength(1);

            // Table & Column Mappings
            this.ToTable("HtmlElements");
            this.Property(t => t.ElementID).HasColumnName("ElementID");
            this.Property(t => t.ElementType).HasColumnName("ElementType");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Style).HasColumnName("Style");
            this.Property(t => t.InnerHtml).HasColumnName("InnerHtml");
        }
    }
}
